package com.ytktt.study.week12.task4.properties;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 自定义kafka配置
 *
 * @author ytk
 */
@ConfigurationProperties(prefix = MQProperties.PREFIX)
@Getter
@Setter
public class MQProperties {

    public static final String PREFIX = "financial.mq";

    /** 消息队列类型 */
    private MQType type = MQType.KAFKA;

    /** kafka配置数据 */
    private FinancialKafkaProperties kafka = new FinancialKafkaProperties();

    @Getter
    @Setter
    public static class FinancialKafkaProperties {

        /** 主题 */
        private String topic;

        /** 分区 */
        private int partition = 0;

        /** replicas-factor */
        private int replicas = 1;

        /** 生产者配置 */
        private FinancialKafkaProducerProperties producer = new FinancialKafkaProducerProperties();

        /** 消费者配置 */
        private FinancialKafkaConsumerProperties consumer = new FinancialKafkaConsumerProperties();
    }

    @Getter
    @Setter
    public static class FinancialKafkaProducerProperties {

        /** 是否是生产者 */
        private Boolean enable = false;
    }

    @Getter
    @Setter
    public static class FinancialKafkaConsumerProperties {

        /** 是否是消费者 */
        private Boolean enable = false;

        /** 监听的分区 */
        private int partition = 0;

        /** 异常处理器 */
        private String errorHandler = "defaultConsumerErrorHandler";
    }
}
